package com.ryskoo.catering.vendortemplatereldetail.repository;

import com.ryskoo.catering.constant.HCLCacheConstant;
import com.ryskoo.catering.vendortemplatereldetail.domain.VendorTemplateRelDetailPO;
import com.ryskoo.framework.core.repository.BasicRedisImpl;
import com.ryskoo.framework.core.utils.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Repository;

import javax.annotation.PostConstruct;
import java.util.List;

@Primary
@Repository
public class VendorTemplateRelDetailRedisImpl extends BasicRedisImpl<VendorTemplateRelDetailPO> implements IVendorTemplateRelDetailRepository {

    @Autowired
    private RedisUtil redisClient;
    @Autowired
    private IVendorTemplateRelDetailRepository vendorTemplateRelDetailRepository;

    @PostConstruct
    public void init() {
        this.setDao(vendorTemplateRelDetailRepository);
        this.setRedisClient(redisClient);
    }

    public VendorTemplateRelDetailRedisImpl() {
        super(HCLCacheConstant.HCL_VENDORTEMPLATERELDETAIL_KEY);
    }

    @Override
    public void deleteByMainUuids(List<String> mainUuids) {
        vendorTemplateRelDetailRepository.deleteByMainUuids(mainUuids);
    }

    @Override
    public List<VendorTemplateRelDetailPO> getByMainUuid(String mainUuid,boolean useStatus,boolean status) {
        return vendorTemplateRelDetailRepository.getByMainUuid(mainUuid,useStatus,status);
    }

    @Override
    public void changeStatus(String detailUuid,boolean status) {
        vendorTemplateRelDetailRepository.changeStatus(detailUuid,status);
    }
}